def practise(list1, list2):
    result = []

    i = j = 0
    while i < len(firstList) and j < len(secondList):
        if firstList[i][1] < secondList[j][0]:
            i += 1
        elif secondList[j][1] < firstList[i][0]:
            j += 1
        else:  # 区间有重叠
            a = max(firstList[i][0], secondList[j][0])
            b = min(firstList[i][1], secondList[j][1])
            result.append([a, b])
            if firstList[i][1] < secondList[j][1]:
                i += 1
            else:
                j += 1
    return result


firstList = [[0, 2], [5, 10], [13, 23], [24, 25]]
secondList = [[1, 5], [8, 12], [15, 24], [25, 26]]
print(practise(firstList, secondList))
